package com.gexin.controller.system.user;

import java.util.List;

import com.alibaba.fastjson.JSONObject;
import com.gexin.common.model.ApiResponse;
import com.gexin.common.utils.DateUtil;
import com.gexin.core.web.SystemBaseController;
import com.gexin.model.excel.AdminLogExcel;
import com.jfinal.ext.route.ControllerBind;
import com.jfinal.upload.UploadFile;
import com.xuxueli.poi.excel.ExcelImportUtil;

/**
 * excel导入导出
 * @author 肖得明 
 */
@ControllerBind(controllerKey = "/system/demo/excel", viewPath = "WEB-INF/system/admin/")
public class AdminExcelDemoController extends SystemBaseController {

	// 首页 查询所有的 一级菜单
	public void index() {
		render("admin_demo_excel.html");
	}

	//导入excel 数据
	public void upload_file() {
		UploadFile f = getFile();
		ApiResponse  api  =new ApiResponse(true, "success");
		api.setData(JSONObject.toJSONString(f));
		renderJson(api);
	}
	
	//演示导入数据
	public void in_data() {
		String  remark_text=  getPara("remark_text");
		String  channel=  getPara("channel");
		String  file_name=  getPara("file_name");
		List<Object> list = ExcelImportUtil.importExcel(file_name,AdminLogExcel.class);
		success(list);		
	}
	
	
	//演示导出数据
	public void  out_data(){
		
	}

	//图片上传的类
	public void  PostImgHandle(){
		String type =  getPara("type");
		String[] file_name =  getParaValues("file_name");
		success();
	}
	//图片上传代码
	public void upload_Img() {
		UploadFile f = getFile("file",DateUtil.getDate("yyyyMMdd"));
		ApiResponse  api  =new ApiResponse(true, "success");
		api.setData(JSONObject.toJSONString(f));
		renderJson(api);
	}
	
	
}
